package com.lan.springbootdruid.service.impl;

import com.lan.springbootdruid.datasource.TargetDataSource;
import com.lan.springbootdruid.entity.User;
import com.lan.springbootdruid.enums.DataSourceKey;
import com.lan.springbootdruid.mapper.UserMapper;
import com.lan.springbootdruid.service.CityService;
import com.lan.springbootdruid.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author: Lan
 * @date: 2019/5/6 11:21
 * @description:
 */
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public User getUserById(int id) {
        return userMapper.getUserById(id);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public int updateUserName(int id) {
        System.out.println("22222 = " + 2222);
        int i = userMapper.updateUserName(id);
        System.out.println("1111 = " + 1111);
        return i;
    }
}
